#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll sum[N], k;
int a[N], n;
bool check(int left, int right) {
    int mid = (left + right) / 2;
    ll ans = (mid - left) * a[mid] - (sum[mid - 1] - sum[left - 1]) +
             (sum[right] - sum[mid]) - (right - mid) * a[mid];
    return ans <= k;
}
int ans;
int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    for (int i = 1, j = 1; i <= n; i++) {
        while (j <= n && check(i, j)) {
            ++j;
        }
        ans = max(ans, j - i);
    }
    cout << ans << endl;
    return 0;
}